"use strict";
// class Greeter {
//     greeting: string;
//     greeting2:number;
//     constructor(message: string,num: number) {
//         this.greeting = message;
//         this.greeting2 = num;
//     }
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
//     greet() {
//         return "Hello, " + this.greeting + this.greeting2;
//     }
// }
// let greeter = new Greeter("world",123);
// //console.log(greeter.greet());
// let test1:number = 123;
// let test2:string = '111';
// test1 += 1;
// //console.log(test1);
// function fn(num:number):number{
//     return 123 * num;
// }
// class Parent {
//     greeting: string;
//     greeting2:number;
//     constructor(message: string,num: number) {
//         this.greeting = message;
//         this.greeting2 = num;
//     }
//     greet() {
//         return "Hello, " + this.greeting + this.greeting2;
//     }
// }
// class Child extends Parent{
//     greeting3:boolean = false;
//     // constructor(greeting: string,greeting2:number){
//     //     super(greeting,greeting2);
//     // }
//     getData():string{
//         console.log(this.greeting);
//         console.log(this.greeting2);
//         return this.greeting + this.greeting2;
//     }
// }
// let child = new Child('string',123);
// // console.log(child.greeting3);
// //console.log(child.getData());
var arr1 = ['11'];
var arr2 = [111];
var arr3 = ['111', 11];
var arr4Enum;
(function (arr4Enum) {
    arr4Enum[arr4Enum["data1"] = 0] = "data1";
    arr4Enum[arr4Enum["data2"] = 1] = "data2";
    arr4Enum[arr4Enum["data3"] = 2] = "data3"; //2
})(arr4Enum || (arr4Enum = {}));
var arr4 = arr4Enum.data1; //获取索引
function fn1() {
    return 123;
}
function fn2() {
    return '123';
}
function fn3() {
    console.log('fn3');
}
function fn4(number1, number2) {
    return number1 + number2;
}
//函数类型
var fnType;
var dataobj1 = {
    name: '小陈',
    age: 22
};
var dataobj2 = {
    names: ['名称1'],
    fn1: function (item) {
        this.names.push(item);
        return this.names;
    }
};
// console.log(dataobj2.fn1('test'),'dataobj2');
var unionType; //多种类型赋值
//never
var never;
//不能将其他类型转化为never类型
// never = 111;
//never一般用于抛出异常
function throwErrer(msg) {
    throw new Error(msg);
}
// console.log(throwErrer('抛出异常'))
//never 死循环
function loop() {
    while (true) { }
}
var sumValue = {
    money: 20,
    count: function (value) {
        this.money = value;
    }
};
var handleCount = {
    name: 'Henry',
    sumValue: sumValue,
    friends: ['bucky', 'elyse']
};
//类
var Person = /** @class */ (function () {
    function Person(name, sex) {
        //public 公开  private 私有 只能在本类访问   protected只能在本类和子类访问
        this.name = '名称'; //初始化
        this._age = 22; //初始化
        this.sex = '男'; //初始化
        this.name = name;
        this.sex = sex;
    }
    Object.defineProperty(Person.prototype, "setAge", {
        set: function (value) {
            this._age = value;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(Person.prototype, "getAge", {
        get: function () {
            return this._age;
        },
        enumerable: false,
        configurable: true
    });
    Person.username = '用户名称'; //静态属性
    return Person;
}());
// let person = new Person('新名称',33,'女');
// console.log(person.name);
//继承
var Student = /** @class */ (function (_super) {
    __extends(Student, _super);
    function Student(name, sex) {
        var _this = _super.call(this, name, sex) || this;
        _this.studentId = 123;
        return _this;
        //console.log(this.studentId);
    }
    return Student;
}(Person));
var interfaceObj = {
    username: '用户名',
    sex: '男',
    salary: 7000,
    randomStr: '111',
    funtion1: function () {
        console.log('函数');
    }
};
//implements实现
var InterfaceClass = /** @class */ (function () {
    function InterfaceClass() {
        this.username = '用户名';
        this.sex = '男';
        this.salary = 7000;
        this.randomStr = '111';
        this.funtion1 = function () {
            console.log('函数');
        };
        this.id = 12;
    }
    return InterfaceClass;
}());
var InterfaceClassChild = /** @class */ (function (_super) {
    __extends(InterfaceClassChild, _super);
    function InterfaceClassChild(data1, data2) {
        var _this = _super.call(this) || this;
        _this.data1 = data1;
        _this.data2 = data2;
        return _this;
    }
    InterfaceClassChild.prototype.get_a_and_b_data = function () {
        return this.data1 + '|' + this.data2;
    };
    return InterfaceClassChild;
}(InterfaceClass));
// let interfaceClassChild = new InterfaceClassChild('data1','data2');
// console.log(interfaceClassChild.get_a_and_b_data());
//泛型 根据入参变成相对应的类型
function identify1(age) {
    return age;
}
function identify2(num) {
    return num;
}
//console.log(identify2(1)); //只能传number
function identify3(obj) {
    return obj;
}
//console.log(identify3({length:123})); //必须有个对象 里面有个length
var CountNumber = /** @class */ (function () {
    function CountNumber(num1, num2) {
        this.number1 = num1;
        this.number2 = num2;
    }
    CountNumber.prototype.calcalate = function () {
        // return this.number1 + this.number2;
        return (+this.number1) + (+this.number2); //因为泛型不能相乘 所以强加上+号 ts添加 
    };
    return CountNumber;
}());
var countNumber = new CountNumber(10, 20);
// console.log(countNumber.calcalate());
function buildName(x, y) {
    return x + y;
}
;
console.log(buildName('Bob', 'Adams'));
function createZoo() {
    return {
        kind: '111',
        size: 111
    };
}
